package com.rcloud.server.sealtalk.controller;

import com.rcloud.server.sealtalk.domain.IndexBanner;
import com.rcloud.server.sealtalk.domain.SysConfig;
import com.rcloud.server.sealtalk.model.response.APIResult;
import com.rcloud.server.sealtalk.model.response.APIResultWrap;
import com.rcloud.server.sealtalk.service.IndexBannerService;
import com.rcloud.server.sealtalk.service.SysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 轮播图相关接口
 *
 * @author ruoyi
 */
@Api(tags = "轮播图相关接口")
@Slf4j
@RestController
@RequestMapping("/index/banner")
@AllArgsConstructor
public class IndexBannerController extends BaseController {
    @Autowired
    private IndexBannerService indexBannerService;

    @ApiOperation(value = "根据类型获取轮播信息 轮播类型 1.广告页图片轮播 2.广告页视频轮播")
    @RequestMapping(value = "/{img_type}", method = RequestMethod.GET)
    public APIResult<Object> queryIndexBanner(@PathVariable Integer img_type) {
        //根据类型获取轮播信息
        Example example = new Example(IndexBanner.class);
        example.createCriteria().andEqualTo("imgType", img_type)
                .andEqualTo("status");
        example.setOrderByClause("upload_time DESC");
        List<IndexBanner> bannerList = indexBannerService.getByExample(example);
        return APIResultWrap.ok(bannerList);
    }




}
